﻿@model FieldControlViewModel
@{
	string dataVal = string.Empty;
	string dataValMsg = string.Empty;
	if (Model.EnableNull)
	{
		dataVal += " data-val-required=\"不能为空\" ";
	}
	if (!string.IsNullOrEmpty(Model.Settings[0]))
	{
		dataVal += " data-val-length-max=\"" + Model.Settings[0] + "\" data-val-length=\"字符最大长度为" + Model.Settings[0] + "\"";
	}
	if (!string.IsNullOrEmpty(dataVal))
	{
		dataVal += " data-val=\"true\" ";
		dataValMsg = " data-valmsg-for=\"" + Model.Prefix + Model.FieldName + "\" data-valmsg-replace=\"true\"";
	}
}
<div class="layui-input-inline" style="width:75%;">
	<input type="text" class="layui-input" name="@Model.Prefix@Model.FieldName" id="@Model.Prefix@Model.FieldName" value="@Model.FieldValue" @Html.Raw(dataVal) />
</div>
<div class="layui-input-inline layui-input-company" style="width:100px;">
	@{ 
		if (Model.Settings[2].ToBoolean())
		{
		<button class="layui-btn layui-btn-sm layuiadmin-btn-list" type="button" onclick="@{@Model.Prefix@Model.FieldName}CheckIsExist()">检查是否重复</button>
		}
	}
</div>
<span class="layui-bg-green" style="display:inline-block;">@Model.Description</span>
<span class="field-validation-valid" style="color:red;" @Html.Raw(dataValMsg)></span>
<script type="text/javascript">
	function @{@Model.Prefix@Model.FieldName}CheckIsExist() {
		var ctlID = "@Model.Prefix@Model.FieldName";
		var checkValue = $("#" + ctlID).val();
		var checkType = "Title";
		if (CheckIsExist(checkType, checkValue)) {
			$(".field-validation-valid[data-valmsg-for=" + ctlID + "]").html("该标题已存在");
		}
		else {
			$(".field-validation-valid[data-valmsg-for=" + ctlID + "]").html("");
		}
	}
</script>